//
//  MeatMineTableViewCell.m
//  PigMarket
//
//  Created by 张敬 on 2019/7/30.
//  Copyright © 2019年 pigmarket.oc. All rights reserved.
//

#import "MeatMineTableViewCell.h"

@interface MeatMineTableViewCell()

@property (nonatomic, strong) NSMutableArray *valueArray;
@property (nonatomic, strong) NSArray *titles;


@end


@implementation MeatMineTableViewCell

- (void)setupUI{
    
    [self addSubview:self.tribalLab];
    [self addTitleList];
    
}

- (void)setupLayout{
    
    {
        _tribalLab.size = CGSizeMake(KScreenWidth - 60, 20);
        _tribalLab.mj_x = 15;
        _tribalLab.mj_y = 30;
        
          NSMutableAttributedString *aims = [@"武清部落 " createAttributingByIcon:nil downIndexImage:@"meat_mine_doublearrow" textColor:KBlackColor font:mMediumFont(16)];
        _tribalLab.attributedText = aims;
    }
}


- (void)addTitleList{
    
    __block CGFloat gap = (KScreenWidth - 30) / 4.f;
    @weakify(self);
    [self.values enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        
        @strongify(self);
        UILabel *valueLab = [UILabel makeLabelWithText:obj textColor:UIColorFromRGB(0x424242) font:mMediumFont(17) textAliment:1];
        valueLab.frame = CGRectMake( gap *idx, 62, gap, 20);
        
        UILabel *titleLab = [UILabel makeLabelWithText:self.titles[idx] textColor:UIColorFromRGB(0x808080) font:mFont(12) textAliment:1];
        titleLab.frame = CGRectMake(gap *idx, valueLab.bottom + 4, gap, 18);
        
        [self addSubview:valueLab];
        [self addSubview:titleLab];
        
        if (idx >0) {
            CAShapeLayer *line = [CAShapeLayer layer];
            line.fillColor = UIColorFromRGB(0x919191).CGColor;
            UIBezierPath *path = [UIBezierPath bezierPathWithRect:CGRectMake(gap *(idx), 73, 1, 20)];
            line.path = path.CGPath;
            [self.layer addSublayer:line];
        }
        
    }];
    
}


#pragma mark -  setter and getter methods

- (UILabel *)tribalLab{
    
    if (!_tribalLab) {
        _tribalLab = [UILabel new];
    }
    return _tribalLab;
}

- (NSArray *)titles{
    
    if (!_titles) {
        _titles = @[@"今日访客", @"今日买家", @"今日收益", @"今日收藏"];
    }
    return _titles;
}


- (NSArray *)values{
    
    if (!_values) {
        _values = @[@"293", @"26", @"¥647", @"147"];
    }
    return _values;
}


@end
